/*
 * @Author: szx
 * @Date: 2022-01-05 13:02:29
 * @LastEditTime: 2022-01-05 13:13:12
 * @Description:
 * @FilePath: \leetcode\400-499\406\406.js
 */
/**
 * @param {number[][]} people
 * @return {number[][]}
 */
var reconstructQueue = function (people) {
    people.sort((a, b) => {
        if (b[0] != a[0]) {
            return b[0] - a[0];
        } else {
            return a[1] - b[1];
        }
    });
    const queue = [];
    for(let i = 0; i < people.length; i++) {
        queue.splice(people[i][1], 0, people[i])
    }
    return queue
};
